package dcedit.util;

// Import Java SDK Classes
import javax.swing.*;
import javax.swing.table.TableCellEditor;

/** TemplateTokenTable class */
public class TemplateTokenTable extends JTable {
   /** Serial Version UID version for serializable classes */
   public static final long serialVersionUID = 1300399928522L;

   /** Constructor */
   public TemplateTokenTable() {
      this(new TemplateTokenTableModel());
   } // END constructor

   /** Constructor */
   public TemplateTokenTable(TemplateTokenTableModel model) {
      super(model);
   } // END constructor

   @Override
   public TableCellEditor getCellEditor(int row, int column) {
      final JComponent COMPONENT = Constants.TEMPLATE_TOKEN_TABLE_MODEL.getToken(row).getDisplayComponent();

      if(1 == column) {
         if(COMPONENT instanceof TemplateToken.TemplateTokenComboBox) {
            return new DefaultCellEditor((TemplateToken.TemplateTokenComboBox)COMPONENT);
         } // END if

         if(COMPONENT instanceof TemplateToken.TemplateTokenTextField) {
            return new DefaultCellEditor((TemplateToken.TemplateTokenTextField)COMPONENT);
         } // END if
      } // END if

      return super.getCellEditor(row, column);
   } // END getCellEditor
} // END class TemplateTokenTable